home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / patch / pagestream / pgs32tu3 / scripts.lha / RotateAboutPoint.rexx < prev    next >
OS/2 REXX Batch file  |  1996-11-20  |  6KB  |  181 lines

  1. /* $VER: RotateAboutPoint.rexx 1.1a (20.11.96)
  2.    Copyright 1996 SoftLogik Publishing Corporation
  3.    May not be distributed without SoftLogik Publishing Corporation's express written permission */
  4.  
  5. OPTIONS RESULTS
  6. TRACE OFF
  7.  
  8. ADDRESS 'PAGESTREAM'
  9.  
  10. /* Get the current rotation values and strip off the degree and measurement symbols */
  11. getobject type objtype rotation rstem about astem
  12.  
  13. /* Are there any objects selected? If not, alert the user */
  14. if rc>0 then do
  15.     allocarexxrequester '"RotateAboutPoint Alert"' 376 59
  16.     hDialog=result
  17.     addarexxgadget hDialog EXIT 290 42 70 label "Exit"
  18.         Exithandle=result
  19.     addarexxgadget hDialog TEXT 8 10 360 border none string "'There are no objects selected. Select one or'"
  20.     addarexxgadget hDialog TEXT 8 20 360 border none string "'more objects and then play the script again.'"
  21.     doarexxrequester hDialog
  22.     freearexxrequester hDialog
  23.     EXIT
  24. end
  25.  
  26. /* if objects are locked, we don't want the actual lock alert box opening */
  27. /* 2 or more times, so let's simulate it and temporarily reset the lock */
  28. /* status if required. */
  29. getobjectlock
  30. lockstatus=result
  31. ignorehandle=1
  32. lockaction=0
  33. if lockstatus='ON' | lockstatus='UNKNOWN' then do
  34.     allocarexxrequester '"Locked"' 254 55
  35.     hDialog=result
  36.     addarexxgadget hDialog EXIT 172 38 70 label "_Cancel"
  37.         cancelhandle=result
  38.     addarexxgadget hDialog EXIT 12 38 70 label "_Ignore"
  39.         ignorehandle=result
  40.     addarexxgadget hDialog EXIT 92 38 70 label "_Unlock"
  41.         unlockhandle=result
  42.     addarexxgadget hDialog TEXT 8 10 232 border none string "'A selected object is locked.'"
  43.     doarexxrequester hDialog
  44.     lockaction=result
  45.     freearexxrequester hDialog
  46.  
  47.     /* If Cancel, then exit */
  48.     if lockaction=cancelhandle then do
  49.         exit
  50.     end
  51.     /* If Unlock, then unlock. If Ignore, temporarily unlock */
  52.     /* Note, this doesn't properly handle the situation of some objects being locked and others not. They'll all be locked at the end of this script. */
  53.     if lockaction=unlockhandle | lockaction=ignorehandle then unlock
  54. end
  55.  
  56. /* PGS3 returns slant and twist. Reduce to rotate and remainder. */
  57. aslant=abs(rstem.slant)
  58. atwist=abs(rstem.twist)
  59. if rstem.slant=rstem.twist then do
  60.     rstem.rotate=rstem.slant||'°'
  61.     rstem.slant='0°'
  62.     rstem.twist='0°'
  63.     end
  64. else do
  65.     if aslant<atwist then do
  66.         rstem.rotate=rstem.slant||'°'
  67.         mult=rstem.slant*-1
  68.         end
  69.     else do
  70.         rstem.rotate=rstem.twist||'°'
  71.         mult=rstem.twist*-1
  72.     end
  73.     rstem.slant=rstem.slant+mult||'°'
  74.     rstem.twist=rstem.twist+mult||'°'
  75. end
  76.  
  77. /* Allocate the Rotate About Point dialog box */
  78. allocarexxrequester '"Rotate About Point"' 290 93
  79.     hDialog=result
  80.  
  81. /* Allocate a list for the about cycle control */
  82. allocarexxlist
  83.     hAboutList=result
  84. addarexxlist hAboutList 'Center'
  85. addarexxlist hAboutList 'Point'
  86.  
  87. /* Add controls to dialog box */
  88. addarexxgadget hDialog EXIT 12 76 70 label "OK"
  89.     hOK=result
  90. addarexxgadget hDialog EXIT 210 76 70 label "Cancel"
  91.     hCancel=result
  92. addarexxgadget hDialog TEXT 8 8 128 border none string "'Rotation Amount'"
  93. addarexxgadget hDialog STRING 64 22 70 label "_Rotate" string rstem.rotate
  94.     hRotate=result
  95. addarexxgadget hDialog STRING 64 36 70 label "_Slant" string rstem.slant
  96.     hSlant=result
  97. addarexxgadget hDialog STRING 64 50 70 label "_Twist" string rstem.twist
  98.     hTwist=result
  99. addarexxgadget hDialog TEXT 146 8 120 border none string "'Rotation Point'"
  100. addarexxgadget hDialog CYCLE 190 22 86 label '"Ab_out"' list hAboutList current 0
  101.     hAbout=result
  102. if astem.mode='POINT' then do
  103.     setarexxgadget hDialog hAbout current 1
  104.     addarexxgadget hDialog STRING 190 36 70 label "_Horz" string astem.x
  105.         hXPoint=result
  106.     addarexxgadget hDialog STRING 190 50 70 label "V_ert" string astem.y
  107.         hYPoint=result
  108.     end
  109. else do
  110.     setarexxgadget hDialog hAbout current 0
  111.     addarexxgadget hDialog STRING 190 36 70 label "_Horz"
  112.         hXPoint=result
  113.     addarexxgadget hDialog STRING 190 50 70 label "_Vert"
  114.         hYPoint=result
  115. end
  116. /* Show dialog box */
  117. doarexxrequester hDialog
  118. action=result
  119.  
  120. /* If Cancel, then exit */
  121. if action=hCancel then signal cancel
  122.  
  123. /* If Rotate, then rotate it and exit */
  124. /* Get gadget status */
  125. getarexxgadget hDialog hRotate string
  126.     dRotate=result
  127. if lastpos('°',dRotate)~=0 then dRotate=left(dRotate,lastpos('°',dRotate)-1)
  128. getarexxgadget hDialog hSlant string
  129.     dSlant=result
  130. if lastpos('°',dSlant)~=0 then dSlant=left(dSlant,lastpos('°',dSlant)-1)
  131. getarexxgadget hDialog hTwist string
  132.     dTwist=result
  133. if lastpos('°',dTwist)~=0 then dTwist=left(dTwist,lastpos('°',dTwist)-1)
  134. getarexxgadget hDialog hXPoint string
  135.     dHorz=result
  136. getarexxgadget hDialog hYPoint string
  137.     dVert=result
  138.  
  139. /* Check for blank text boxes */
  140. if dRotate="" then dRotate=0
  141. if dSlant="" then dSlant=0
  142. if dTwist="" then dTwist=0
  143. if dHorz="" then dHorz=astem.x
  144. if dVert="" then dVert=astem.y
  145.  
  146. /* Determine if the rotation point was changed from center, then set rotation point */
  147. /* strip the msys if they type one. msys abbrevs are not supported by this version */
  148.  
  149. if (right(dHorz,1)<0 | right(dHorz,1)>9) then dHorz=left(dHorz,length(dHorz)-1)
  150. if (right(dHorz,1)<0 | right(dHorz,1)>9) then dHorz=left(dHorz,length(dHorz)-1)
  151. if (right(dHorz,1)<0 | right(dHorz,1)>9) then dHorz=left(dHorz,length(dHorz)-1)
  152. if (left(dHorz,1)<0 | left(dHorz,1)>9) then dVert=left(dVert,length(dVert)-1)
  153. if (left(dHorz,1)<0 | left(dHorz,1)>9) then dVert=left(dVert,length(dVert)-1)
  154. if (left(dHorz,1)<0 | left(dHorz,1)>9) then dVert=left(dVert,length(dVert)-1)
  155.  
  156. refresh wait
  157.  
  158. /* Rotate About Center or Point? */
  159. getarexxgadget hDialog hAbout current
  160. if result=0 then do
  161.     editobject aboutcenter
  162.     end
  163. else do
  164.     editobject about dHorz dVert
  165. end
  166.  
  167. dSlant=dSlant+dRotate
  168. dTwist=dTwist+dRotate
  169.  
  170. /* Rotate the selected objects */
  171. editobject skew dSlant dTwist
  172. if lockaction=ignorehandle then lock
  173. refresh continue
  174.  
  175. /* Clean up and Exit */
  176. CANCEL:
  177. freearexxrequester hDialog
  178. freearexxlist hAboutList
  179. exit
  180. return 0
  181.